package com.software.practicecenter.controller;

import com.software.practicecenter.entity.Question;
import com.software.practicecenter.entity.SubPassage;
import com.software.practicecenter.entity.SubPassageDTO;
import com.software.practicecenter.service.SubPassageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/subPassage")
public class SubPassageController {
    @Autowired
    private SubPassageService subPassageService;

    @GetMapping("/findByPassageId/{passageId}")
    public List<SubPassageDTO> findByPassageId(@PathVariable String passageId){
        List<SubPassageDTO> subPassageDTOS = subPassageService.findByPassageId(passageId);
        return subPassageDTOS;
    }

    @GetMapping("/list_back")
    public List<SubPassage> findAllBack(){
        List<SubPassage> all = subPassageService.findAllBack();
        return all;
    }

    @GetMapping("/list")
    public List<SubPassageDTO> findAll(){
        List<SubPassageDTO> all = subPassageService.findAll();
        return all;
    }

    @GetMapping("/findNameByNo/{no}")
    public String findNameByNo(@PathVariable String no){
        SubPassage subPassage = subPassageService.findByNo(no);
        String name = subPassage.getName();
        return name;
    }
}
